package fhp.hlhj.giantfold.adapter

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import fhp.hlhj.giantfold.R
import java.util.ArrayList

/**
 * Created by Administrator on 2018\3\1 0001.
 */
class SelfUnLoginedAdp(private val context: Context,private val datas:ArrayList<String>) :PagerAdapter() {
    override fun isViewFromObject(p0: View?, p1: Any?): Boolean {
        return  p0==p1
    }

    override fun getCount(): Int {
        return Int.MAX_VALUE
    }

    override fun instantiateItem(container: ViewGroup?, position: Int): Any {
        val view = LayoutInflater.from(context).inflate(R.layout.self_unlogin_item, null)
        val img = view.findViewById<ImageView>(R.id.img)
        img.setImageResource(when(position%datas.size){
            0->{
                R.mipmap.dl_img
            }
            1->{
                R.mipmap.dl_imgo
            }
            2->{
                R.mipmap.dl_imgs
            }
            3->{
                R.mipmap.dl_imgt
            }
            else->{
                0
            }
        })
        container?.addView(view)
        return view
    }

    override fun destroyItem(container: ViewGroup?, position: Int, `object`: Any?) {
//        super.destroyItem(container, position, `object`)
    }
}